package com.moyuwanjia;

import com.moyuwanjia.service.Impl.IAccountServiceImpl;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 摸鱼丸加~
 * @create 2022-04-27 16:18
 */
@Data
@AllArgsConstructor
public class test {
    private Integer id;
    private String age;

    /**
     * 这里使用的是注解的方式，所以xml中就全部注释掉
     */
    @Test
    public void test01(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        IAccountServiceImpl iAccountServiceImpl = context.getBean("IAccountServiceImpl", IAccountServiceImpl.class);
        iAccountServiceImpl.findAll().forEach(System.out::println);
    }


    @Test
    public void test02(){
        test test01 = new test(1,"10");
        test test02 = new test(2,"20");
        test test03 = new test(3,"30");
        List<test> list = new ArrayList<>();
        list.add(test01);
        list.add(test02);
        list.add(test03);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        list.stream().forEach(i -> {
            System.out.println("");
        });

        list.forEach(i ->{
            System.out.println(i);
        });

        list.forEach(System.out::println);
        List<String> collect = list.stream().map(i -> {
            return i.age;
        }).collect(Collectors.toList());

        List<test> collect1 = list.stream().filter(i -> i.id != 2).collect(Collectors.toList());

        Function<Integer,String> a = new Function<Integer, String>() {
            @Override
            public String apply(Integer integer) {
                return "123";
            }
        };
    }

}
